/*=================================页面load============================================================*/

function hydtContentLoad(){
	createLeftTopMenuForHYDT();
	queryAllSettings();
	queryHYDTContent(this.opener.newsID);
}

/*=================================信息获取============================================================*/

//根据ID查询对应的行业动态
function queryHYDTContent(newsID){
	if(bXmlHttpSupport) {
    	var sUrl = "queryHYDTContent.action";
    	var params ="newsID="+newsID;
        var request = new XMLHttpRequest();
        request.onreadystatechange = function() {
        	if(request.readyState == 4) {
            	var oRequest = eval('(' + request.responseText + ')');
            	//alert(request.responseText);
            	var HYDT = oRequest.HYDTContent;
            	displayHYDTContent(HYDT);
			}
    	};
    	request.open('POST', sUrl);
    	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
    	request.send(params);
    }
}

/*=================================信息展示============================================================*/

//行业动态页面，生成左上角的目录
function createLeftTopMenuForHYDT(){
	if(bXmlHttpSupport) {
    	var sUrl = "findSettings.action";
    	var params ="item=LeftTopMenu&setKey=xwjj";
        var request = new XMLHttpRequest();
        request.onreadystatechange = function() {
        	if(request.readyState == 4) {
            	var oRequest = eval('(' + request.responseText + ')');
            	//alert(request.responseText);
            	var string = oRequest.settings.setValue;
            	news.innerHTML = string;
			}
    	};
    	request.open('POST', sUrl);
    	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
    	request.send(params);
    }
}

/*=================================数据处理============================================================*/
//将读取的行业动态展示到页面
function displayHYDTContent(HYDT){
	newsTitle.innerHTML = HYDT.title;
	newsAuthor.innerHTML = "来源：" + HYDT.author;
	newsTime.innerHTML = "时间：" + HYDT.lastModified.replace("T", " ");
	var picHTML = createPicString(HYDT.newsImgs);
	realContent.innerHTML = picHTML + HYDT.content;
}

function createPicString(newsImgs){
	var html = "";
	var imgLen = newsImgs.length;
	if (imgLen > 0){
		for (var i = 0; i < imgLen; i++){
			var imgID = newsImgs[i].newsImgID;
			html = html + "<img src='loadImgByID.action?imgID="+ imgID +"'/>";
		}
	}
	return html;
}